import axios from 'axios'
import qs from 'qs'

const service = axios.create({
	baseURL: import.meta.env.VITE_APP_API_URL,
	timeout: 20 * 1000,
	paramsSerializer: params => {
		// 自定义参数序列化函数, get数组用逗号连接
		return qs.stringify(params, { arrayFormat: 'comma' });
	}
})

service.interceptors.request.use(config => {
	config.headers['Content-Type'] = 'application/json;charset=UTF-8'
	return config
}, error => {
})

export default service
